package com.team407.cheyoubang.parse;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.team407.cheyoubang.bean.Bean;


public class Result {
	private Map<String, Object> map;
	public Result(){
		map = new HashMap<String, Object>();
	}
	
	public void put(String key, Object object){
		map.put(key, object);
	}
	
	public int getInteger(String key){
		Object value = map.get(key);
		if(value == null){
			return 0;
		}
		if(value instanceof Integer){
			return (Integer) value;
		}
		return 0;
	}
	
	public String getString(String key){
		Object value = map.get(key);
		if(value == null){
			return null;
		}
		if(value instanceof String){
			return (String) value;
		}
		return null;
	}
	
	public Boolean getBoolean(String key){
		Object value = map.get(key);
		if(value == null){
			return false;
		}
		if(value instanceof Boolean){
			return (Boolean) value;
		}
		return false;
	}
	
	public Bean getBean(String key){
		Object value = map.get(key);
		if(value == null){
			return null;
		}
		if(value instanceof Bean){
			return (Bean) value;
		}
		return null;
	}
	
	@SuppressWarnings("unchecked")
	public List<? extends Bean> getListBean(String key){
		Object value = map.get(key);
		if(value == null){
			return null;
		}
		if(value instanceof List<?>){
			return (List<? extends Bean>) value;
		}
		return null;
	}
}
